layui.use(['form', 'jquery', 'layer','element'], function(){
		var form = layui.form
		,layer = layui.layer
		,$ = layui.jquery;
		
		var element = layui.element; //导航的hover效果、二级菜单等功能，需要依赖element模块			  
		 //监听导航点击
		element.on('nav(demo)', function(elem){
			//console.log(elem)
			layer.msg(elem.text());
		});
		// 获取参数
		var lastname=localStorage.getItem("key");
		if(lastname==null){			
			location.href="login.html";
		}
			// ajs请求
		$.ajax({
				method:"GET",
				url:"/my/userinfo",			
				success:function(res){				
					console.log(res);
					// 把data值给存起来
					localStorage.setItem("use",JSON.stringify(res.data));
					// 给名字赋值
					$(".tml").html(res.data.nickname);					
					$(".pic").attr("src",res.data.user_pic);
				}				
		})
		// 退出的时候的事件
		$(".tuichu").click(function(e){
			e.preventDefault();
			//询问框		
			layer.confirm('是否退出？', {
			  btn: ['是','否'] //按钮
			}, function(){
			  layer.msg('退出成功',function(){
				  time:1000,
				  location.href="login.html";
			  });
			}, function(){
			  layer.msg('不退出', {
			    time: 2000, //20s后自动关闭		    
			  });
			});				
		})
		
		
})





